package ClassFrame;

import GamePlay.CanvasGame;
import javax.microedition.lcdui.Graphics;

/**
 *
 * @author DuyNT3
 */
public class Player{
    public static final int LEVEL_X = 30;
    public static final int LEVEL_Y = 220;
    public static final int SCORE_X = 220;
    public static final int SCORE_Y = 298;
//    public static final int MISS_X = 280;
//    public static final int MISS_Y = 112;
    
    
    
    public static final int MAX_NAME_LEN        = 10;
    
    private CanvasGame gameCanvas;
    private int image;
    private int level;
    private int money;
    private int score;
    private int nameLen;
    private String name;
    private  static int levelup;
    private char[] nameTemp;
//    private static Map map;
    private int count;
    
    public Player(CanvasGame gameCanvas, int image, int level, int score, int money, String name) {
        this.gameCanvas = gameCanvas;
        this.image = image;
        this.level = level;
        this.score = score;
        this.money = money;
        this.name  = name;
        this.nameLen = 0;
     
        this.nameTemp = new char[MAX_NAME_LEN];
//        map = new Map(gameCanvas);
    }

    public void update() {
       
       
    }

    public void paint(Graphics g, Image ima) {        
       
	update();
    }
    
    public void setLevel(final int level){
        this.level = level;
    }
    
    public void setScore(final int score) {
        this.score = score;
    }
    
    public void setMoney(final int miss) {
        this.money = miss;
    }
    
    public void setName(final char[] name) {
        this.name = new String(name);
    }
    
    public void resetName(){
        for (int i=0;i<MAX_NAME_LEN;i++){
            this.nameTemp[i]= InputKey.KEY_SPACE;
        }
    }
    
    public void setNameLength(final int nameLen){
        this.nameLen = nameLen;
    }
    
    public void addChar(final char c) {
        if( this.nameLen < MAX_NAME_LEN ) {
            if(c >= InputKey.KEY_A && c <= InputKey.KEY_Z || c >= InputKey.KEY_a && c <= InputKey.KEY_z) {
                this.nameTemp[this.nameLen] = c;
                ++ this.nameLen;
            }
        }
    }
    
    public void removeChar() {
        if(this.nameLen >= 0) {
            if(this.nameLen > 0)
                -- this.nameLen;
            this.nameTemp[this.nameLen] = '\0';
        }
    }
    public int getLevel() {
        return this.level;
    }
   
    public int getScore() {
        return this.score;
    }
    
    public int getMoney() {
        return this.money;
    }
    
    public String getName() {
        return this.name;
    }
    
    public int getNameLength() {
        return this.nameLen;
    }
    
    public char[] getNameTg() {
        return this.nameTemp;
    }

   public void setName(String name) {
        this.name = name;
    }

    public int getLevelup() {
        return levelup;
    }

    public void setLevelup(int levelup) {
        this.levelup = levelup;
    }

}
